﻿using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Migrations;

#nullable disable

#pragma warning disable CA1814 // Prefer jagged arrays over multidimensional

namespace TrackSystem.EntityFramework.Migrations
{
    /// <inheritdoc />
    public partial class cm4 : Migration
    {
        /// <inheritdoc />
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.CreateTable(
                name: "Loop",
                columns: table => new
                {
                    Id = table.Column<int>(type: "int", nullable: false)
                        .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
                    Name = table.Column<string>(type: "varchar(50)", maxLength: 50, nullable: false)
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    Description = table.Column<string>(type: "varchar(200)", maxLength: 200, nullable: false)
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    PVName = table.Column<string>(type: "longtext", nullable: false)
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    SVName = table.Column<string>(type: "longtext", nullable: false)
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    OPName = table.Column<string>(type: "longtext", nullable: false)
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    Method = table.Column<int>(type: "int", nullable: false),
                    Action = table.Column<bool>(type: "tinyint(1)", nullable: false),
                    Dirction = table.Column<bool>(type: "tinyint(1)", nullable: false),
                    Params_P = table.Column<double>(type: "double", nullable: false),
                    Params_I = table.Column<double>(type: "double", nullable: false),
                    Params_D = table.Column<double>(type: "double", nullable: false),
                    OutHLimit = table.Column<double>(type: "double", nullable: false),
                    OutLLimit = table.Column<double>(type: "double", nullable: false),
                    Setting = table.Column<string>(type: "longtext", nullable: true)
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    HDeadZone = table.Column<int>(type: "int", nullable: false),
                    LDeadZone = table.Column<int>(type: "int", nullable: false),
                    Ratio = table.Column<double>(type: "double", nullable: false),
                    equipId = table.Column<int>(type: "int", nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_Loop", x => x.Id);
                })
                .Annotation("MySql:CharSet", "utf8mb4");

            migrationBuilder.InsertData(
                table: "Logic",
                columns: new[] { "Id", "ClacateFormula", "ConditionFormula", "Description", "Enabled", "Name", "ResultReg", "UpdateWhenChanged", "equipId" },
                values: new object[,]
                {
                    { 1, "Port1_Enabled ? 1 : 0", "Port1_Connected", "Logic for Port1", true, "Logic1", "Port1_Enabled", true, 1 },
                    { 2, "Port2_Enabled ? 1 : 0", "Port2_Connected", "Logic for Port2", true, "Logic2", "Port2_Enabled", true, 2 }
                });

            migrationBuilder.InsertData(
                table: "Loop",
                columns: new[] { "Id", "Action", "Description", "Dirction", "HDeadZone", "LDeadZone", "Method", "Name", "OPName", "OutHLimit", "OutLLimit", "PVName", "Params_D", "Params_I", "Params_P", "Ratio", "SVName", "Setting", "equipId" },
                values: new object[] { 1, true, "定深控制回路", true, 10, 10, 0, "AutoDepth", "CTD1_RO2", 100.0, -100.0, "CTD1_RO1", 0.23999999999999999, 0.5, 1.5, 1.0, "CTD1_RW1", "", 1 });

            migrationBuilder.UpdateData(
                table: "var",
                keyColumn: "Id",
                keyValue: 1,
                column: "Serial",
                value: 0);

            migrationBuilder.UpdateData(
                table: "var",
                keyColumn: "Id",
                keyValue: 2,
                column: "Serial",
                value: 0);

            migrationBuilder.UpdateData(
                table: "var",
                keyColumn: "Id",
                keyValue: 3,
                column: "Serial",
                value: 0);

            migrationBuilder.UpdateData(
                table: "var",
                keyColumn: "Id",
                keyValue: 4,
                column: "Serial",
                value: 0);

            migrationBuilder.UpdateData(
                table: "var",
                keyColumn: "Id",
                keyValue: 5,
                column: "Serial",
                value: 0);

            migrationBuilder.UpdateData(
                table: "var",
                keyColumn: "Id",
                keyValue: 6,
                column: "Serial",
                value: 0);

            migrationBuilder.UpdateData(
                table: "var",
                keyColumn: "Id",
                keyValue: 7,
                column: "Serial",
                value: 0);

            migrationBuilder.UpdateData(
                table: "var",
                keyColumn: "Id",
                keyValue: 8,
                column: "Serial",
                value: 0);

            migrationBuilder.UpdateData(
                table: "var",
                keyColumn: "Id",
                keyValue: 9,
                column: "Serial",
                value: 0);

            migrationBuilder.UpdateData(
                table: "var",
                keyColumn: "Id",
                keyValue: 10,
                column: "Serial",
                value: 0);

            migrationBuilder.UpdateData(
                table: "var",
                keyColumn: "Id",
                keyValue: 11,
                column: "Serial",
                value: 0);

            migrationBuilder.UpdateData(
                table: "var",
                keyColumn: "Id",
                keyValue: 12,
                column: "Serial",
                value: 0);

            migrationBuilder.CreateIndex(
                name: "IX_Loop_Id",
                table: "Loop",
                column: "Id",
                unique: true);

            migrationBuilder.CreateIndex(
                name: "IX_Loop_Name",
                table: "Loop",
                column: "Name",
                unique: true);
        }

        /// <inheritdoc />
        protected override void Down(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropTable(
                name: "Loop");

            migrationBuilder.DeleteData(
                table: "Logic",
                keyColumn: "Id",
                keyValue: 1);

            migrationBuilder.DeleteData(
                table: "Logic",
                keyColumn: "Id",
                keyValue: 2);

            migrationBuilder.UpdateData(
                table: "var",
                keyColumn: "Id",
                keyValue: 1,
                column: "Serial",
                value: 2);

            migrationBuilder.UpdateData(
                table: "var",
                keyColumn: "Id",
                keyValue: 2,
                column: "Serial",
                value: 2);

            migrationBuilder.UpdateData(
                table: "var",
                keyColumn: "Id",
                keyValue: 3,
                column: "Serial",
                value: 2);

            migrationBuilder.UpdateData(
                table: "var",
                keyColumn: "Id",
                keyValue: 4,
                column: "Serial",
                value: 2);

            migrationBuilder.UpdateData(
                table: "var",
                keyColumn: "Id",
                keyValue: 5,
                column: "Serial",
                value: 2);

            migrationBuilder.UpdateData(
                table: "var",
                keyColumn: "Id",
                keyValue: 6,
                column: "Serial",
                value: 2);

            migrationBuilder.UpdateData(
                table: "var",
                keyColumn: "Id",
                keyValue: 7,
                column: "Serial",
                value: 2);

            migrationBuilder.UpdateData(
                table: "var",
                keyColumn: "Id",
                keyValue: 8,
                column: "Serial",
                value: 2);

            migrationBuilder.UpdateData(
                table: "var",
                keyColumn: "Id",
                keyValue: 9,
                column: "Serial",
                value: 2);

            migrationBuilder.UpdateData(
                table: "var",
                keyColumn: "Id",
                keyValue: 10,
                column: "Serial",
                value: 2);

            migrationBuilder.UpdateData(
                table: "var",
                keyColumn: "Id",
                keyValue: 11,
                column: "Serial",
                value: 2);

            migrationBuilder.UpdateData(
                table: "var",
                keyColumn: "Id",
                keyValue: 12,
                column: "Serial",
                value: 2);
        }
    }
}
